import 'package:flutter/material.dart'; // fim简便写法
import 'res/listData.dart';

//  GridView

void main() {
  runApp(MyApp());
}

// 基本结构
class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        appBar: AppBar(title: Text('container  text')),
        body: HomeContent(),
      ),
    );
  }
}

class HomeContent extends StatelessWidget {
// 03 GridView.count
  List<Widget> _getListData() {
    var tempList = listData.map((value) {
      return Container(
        child: Column(
          children: <Widget>[
            Image.network(value['imagesUrl']),
            SizedBox(height: 10),
            Text(
              value['title'],
              textAlign: TextAlign.center,
              style: TextStyle(fontSize: 20),
            )
          ],
        ),
        decoration: BoxDecoration(
            border:
                Border.all(color: Color.fromRGBO(233, 233, 133, 0), width: 1)),
      );
    });
    return tempList.toList();
  }

// 03 GridView.count  Padding  组件
  @override
  Widget build(BuildContext context) {
    return Padding(
        padding: EdgeInsets.fromLTRB(0, 0, 10, 0),
        child: GridView.count(
          // crossAxisSpacing: 10.0, // 水平 子  Widget 之间间距
          // mainAxisSpacing: 10.0, // 垂直 子  Widget 之间间距
          // padding: EdgeInsets.all(10.0),
          crossAxisCount: 2, // 一行的 widget 数量
          childAspectRatio: 1.7, // 宽度和高度的比例
          children: <Widget>[
            Padding(
              padding: EdgeInsets.fromLTRB(10.0, 10.0, 0, 0),
              child: Image.network(
                  'https://ss3.bdstatic.com/70cFv8Sh_Q1YnxGkpoWK1HF6hhy/it/u=2583924128,2045793005&fm=26&gp=0.jpg',
                  fit: BoxFit.cover),
            ),
            Padding(
              padding: EdgeInsets.fromLTRB(10.0, 10.0, 0, 0),
              child: Image.network(
                  'https://ss1.bdstatic.com/70cFvXSh_Q1YnxGkpoWK1HF6hhy/it/u=4104885671,2658462684&fm=11&gp=0.jpg',
                  fit: BoxFit.cover),
            ),
            Padding(
              padding: EdgeInsets.fromLTRB(10.0, 10.0, 0, 0),
              child: Image.network(
                  'https://images.weserv.nl/?url=img1.doubanio.com/view/photo/m/public/p2636695009.webp',
                  fit: BoxFit.cover),
            ),
            Padding(
              padding: EdgeInsets.fromLTRB(10.0, 10.0, 0, 0),
              child: Image.network(
                  'https://images.weserv.nl/?url=img1.doubanio.com/view/photo/m/public/p2636695009.webp',
                  fit: BoxFit.cover),
            ),
            Padding(
              padding: EdgeInsets.fromLTRB(10.0, 10.0, 0, 0),
              child: Image.network(
                  'https://images.weserv.nl/?url=img1.doubanio.com/view/photo/m/public/p2636695009.webp',
                  fit: BoxFit.cover),
            ),
            Padding(
              padding: EdgeInsets.fromLTRB(10.0, 10.0, 0, 0),
              child: Image.network(
                  'https://images.weserv.nl/?url=img1.doubanio.com/view/photo/m/public/p2636695009.webp',
                  fit: BoxFit.cover),
            )
          ],
        ));
  }
}
